/**
 * 
 */
package vn.support.connection.response.processor.impl;

import vn.support.connection.Connection;
import vn.support.connection.RequestConnection;
import vn.support.connection.response.processor.AbstractResponseProcessor;
import vn.support.core.dto.DataObject;
import vn.support.core.dto.SessionData;
import vn.support.core.dto.Staff;
import vn.support.system.SystemProperties;

/**
 * @author nttuyen
 *
 */
public class StaffToStaffChatProccessor extends AbstractResponseProcessor {

    @Override
	public DataObject process(DataObject data) {
        String response = data.get(Connection.DTO_RESPONSE_DATA);
        if(!"".equals(response) && response != null) {
            DataObject system = SystemProperties.getData();
            SessionData session = system.get(SessionData.class.getName());

            DataObject requestData = data.get(Connection.DTO_REQUEST_DATA);
            Staff staff = requestData.get(Staff.class.getName());

            //TODO: accept chat
            DataObject aceptChat = new DataObject(Connection.ACCEPT_CHAT_ACTION);
            aceptChat.set("sessionid", session.getSessionId());
            aceptChat.set("chatsessionid", response);
            aceptChat.set("visitorsessionid", staff.getSessionId());
            aceptChat.set(Connection.RESPONSE_PROCESSOR, new StaffChatProcessor());
            Connection connection = new RequestConnection();
            connection.execute(aceptChat);
        }

		return data;
	}
	
}
